﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model;

namespace com.lover.astd.common.logicexe.equip
{
    public class WeaponExe : ExeBase
    {
        public WeaponExe() { _name = ConfigStrings.S_Weapon; _readable = ConfigStrings.SR_Weapon; }
        public override void init_data() 
        {
            if (_user.Level < 120) return;
            ServiceFactory.getEquipManager().handleWeaponsUpgrade(_proto, _logger, _user, true);
            refreshUi();
        }
        public override long execute()
        {
            if (_user.Level < 120) return next_day();
            Dictionary<string, string> conf = getConfig();
            if (conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true"))
            {
                int result = 0;
                do { result = ServiceFactory.getEquipManager().handleWeaponsUpgrade(_proto, _logger, _user, false); }
                while (result == 0);
                refreshUi();
            }
            return an_hour_later();
        }
    }
}
